


from abc import ABC, abstractmethod

from utils import DataUtils
from utils.RedisUtils import RedisUtil


class ATradeApi(ABC):
    BLogin = None

    ADecoratorSwitch = None

    redis = RedisUtil()
    """
     登录信息
    """
    def __init__(self,BLogin):
        self.BLogin = BLogin

    def setADecoratorSwitch(self,ADecoratorSwitch):
        self.ADecoratorSwitch = ADecoratorSwitch

    """
    开始交易
    """
    def makeTrade(self):
        if self.getIndexLotteryInfo():
            return
        self.getDoingLotteryInfo()
        self.getHistoryData()
        if self.BLogin.stop:
            if self.ADecoratorSwitch is None:
                print(f"{self.BLogin.userPhone}  模式选择为空,请设置模式")
            self.switchModelAndModelData()
            self.buy()
            self.getUserInfo()
            print(f"{DataUtils.getDate()} ======================")

    """
      切换模式或者切换 模式,and 切换 childrenIndex 
    """
    def switchModelAndModelData(self):
        self.ADecoratorSwitch.switchModel()

    def getWorkflowName(self,workflowName):
        return self.BLogin.bInfo + "   " + workflowName



    """
     获取首页未开奖的数据
    """
    @abstractmethod
    def getIndexLotteryInfo(self):
        pass
    """
     获取正在开奖的那一期数据
    """
    @abstractmethod
    def getDoingLotteryInfo(self):
        pass

    """
      获取下注历史及其开奖数据
    """
    @abstractmethod
    def getHistoryData(self):
        pass

    """
      买入流程
    """
    @abstractmethod
    def buy(self):
        pass


    """
        获取用户信息
    """
    @abstractmethod
    def getUserInfo(self):
        pass

    """
        充值和支付,这里不需要做什么改动了
    """

    @abstractmethod
    def chargeAndPay(self):
        pass